package org.vestbjergbyggecenter.Model;

public class Contractor {
	public int contractorID;
	public long CVR;
	public String contractorName;
	public Person contactPerson;
	
	//Constructor
	public Contractor (int newContractorID, long newCVR, String newContractorName, int newContactID, String newContactName, long newContactCPR, String newContactAddress, long newContactPostalCode, String newContactCity, String newContactPhone)
	{
		this.contractorID=newContractorID;
		this.CVR=newCVR;
		this.contractorName=newContractorName;
		contactPerson=new Person(newContactID, newContactName, newContactCPR, newContactAddress, newContactPostalCode, newContactCity, newContactPhone);
	}	
	
	//Method to set the ID.
	public void setContractorID(int newContractorID)
	{
		this.contractorID=newContractorID;
	}
	
	//Method to get the ID.
	public int getContractorID()
	{
		return contractorID;
	}
	
	//Method to set the CVR.
	public void setContractorCVR(long newCVR)
	{
		this.CVR=newCVR;
	}
	
	//Method to get the CVR.
	public long getContractorCVR()
	{
		return CVR;
	}
	
	//Method to set the contractor name.
	public void setContractorName(String newContractorName)
	{
		this.contractorName=newContractorName;
	}
	
	//Method to get the contractor name.
	public String getContractorName()
	{
		return contractorName;
	}
	
	//Method to change the contact person
	public void setContactPerson(int newContactID, String newContactName, long newContactCPR, String newContactAddress, long newContactPostalCode, String newContactCity, String newContactPhone)
	{
		contactPerson=new Person(newContactID, newContactName, newContactCPR, newContactAddress, newContactPostalCode, newContactCity, newContactPhone);
	}
	
	//Method that shows the orders of the contractor.
	//ID based.
	public void printContractorOrders(int selectedContractorID)
	{
		if(getContractorID()==selectedContractorID)
		{
			System.out.println("Contractor " + getContractorName() + " with the ID " +  getContractorID()+ " has these orders:");
			for(Order order: OrderRecords.getInstance().getOrders())
			{
				if(order.getCustomer().getID()==selectedContractorID)
				{
					System.out.println();
					System.out.println("Order ID:" + order.getId() + " ordering date: " + order.getOrderingDate() + " delivery date: " + order.getDeliveryDate() + " total price: " + order.getTotalPrice() + " status: " + order.getStatus());
				}
			}
		}
		else
		{
			System.out.println("Please insert the correct contractor ID.");
		}
	}

}
